Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: Render [src] links for trait implementors #44920

Merged
merged 5 commits into from Oct 3, 2017

Conversation

vi
Copy link
Contributor

@vi vi commented Sep 29, 2017

Should close #43893.

No tests [yet].

r? @QuietMisdreavus

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @QuietMisdreavus (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@shepmaster
Copy link
Member

No tests [yet].

Do you expect there to be tests in this PR? I'm going to assume "yes" and mark this as effectively a WIP.

@shepmaster shepmaster added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 29, 2017
@QuietMisdreavus
Copy link
Member

The last time i added [src] links i didn't add tests for them, but i have discovered the test src/test/rustdoc/src-links.rs that ensures these are present for full-file links, or other tests like issue-34274.rs that checks this for specific place. If you want to set up a test for this you can use that latter file as a base, and i can walk you through it. (Personally i wouldn't gate the PR on them, but since other [src] links are tested it would be good to cover that.)

The PR as-is seems to put the links in a place where the CSS isn't expecting to style them. This leaves them looking weird when adjacent to other src links, like here on Iterator:

image

I'd like to get with @GuillaumeGomez to double-check what the best CSS change for this is, but I'm pretty sure that's all it will take to get these right.

@vi
Copy link
Contributor Author

vi commented Sep 29, 2017

No tests [yet].

Do you expect there to be tests in this PR? I'm going to assume "yes" and mark this as effectively a WIP.

If this is required. [yet] means "if needed per some rues there will also be a test, but if the change is too trivial and/or the test environment is too tricky to setup and/or there is some impending change devaluing existing tests then not".

@QuietMisdreavus
Copy link
Member

Thanks for writing that test! The last thing i wanted to make sure this had was the CSS change we discussed on Gitter yesterday. @GuillaumeGomez suggested adding the following block to src/librustdoc/html/static/rustdoc.css:

ul.item-list > li > .out-of-band {
    font-size: 19px;
}

And then changing the part that sets the font-family for all the sans-serif text to add ul.item-list > li > .out-of-band to its list of targets. These changes will make sure the [src] links look like all the others, since the existing CSS missed these new ones.

@GuillaumeGomez
Copy link
Member

I don't even see any css update. Did you forgot to push the file?

@vi
Copy link
Contributor Author

vi commented Oct 1, 2017

Saw the messages, implemented the CSS change.

@vi
Copy link
Contributor Author

vi commented Oct 1, 2017

Means "why not spaces"? Because of other indenting whitespace in this file is tabs.

Continued list of targets which was split into mutiple lines is additionally indented to avoid blending with the rules part which is singly indented.

A change suggested by @GuillaumeGomez and @QuietMisdreavus.

Also slight reindenting of the appropriate CSS section.
@vi vi force-pushed the rustdoc_implementors_src_link branch from b3b731d to 67c9af5 Compare October 1, 2017 13:21
@vi
Copy link
Contributor Author

vi commented Oct 1, 2017

Just put it on the next line and it's fine, no?

Mainly because of I didn't notice a precedent of multi-line target line nearby and just did as I usually do.

Fixed and re-pushed.

the need of the alignment

To allow assumption that each non-indented line is some section (oneline or multiline), not a continuation of something previous. But since non-indented style is already used elsewhere in the file, it's better to just follow it.


// ignore-cross-compile

#![crate_name = "foo"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all unneeded empty lines in here (like in the impl blocks).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which empty lines? Before and after the // ignore-corss-compile? They are just retained from issue-34274.rs, which served as a template. I don't think they should be removed (especially the first empty line).

like in the impl blocks

Means "and likewise remove them in impl blocks" or "like you did in impl blocks"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this:

// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-cross-compile

#![crate_name = "foo"]

pub trait SomeTrait {}
pub struct SomeStruct;

// @has foo/trait.SomeTrait.html '//a/@href' '../src/foo/issue-43893.rs.html#23-26'
impl SomeTrait for usize {}

// @has foo/trait.SomeTrait.html '//a/@href' '../src/foo/issue-43893.rs.html#29-32'
impl SomeTrait for SomeStruct {}

Copy link
Contributor Author

@vi vi Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl SomeTrait for usize {}

{}

Other [src] link test (issue-34274.rs) tests for single line link. I thought it would be useful to also provide multiple line implementation, so that the link contains line range, not a single line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having multi-line tests is useful to make sure that the link points to the full span.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I contracted one impl to one line, but left the other impl as three lines in the update.

per @GuillaumeGomez's sample, but with one change.
@vi
Copy link
Contributor Author

vi commented Oct 2, 2017

@GuillaumeGomez, Done, but one impl is intentionally left as 3 lines instead of just {}.

@GuillaumeGomez
Copy link
Member

Ok, then it's all good now. Thanks!

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Oct 3, 2017

📌 Commit acef039 has been approved by GuillaumeGomez

@bors
Copy link
Contributor

bors commented Oct 3, 2017

⌛ Testing commit acef039 with merge 61bad30...

bors added a commit that referenced this pull request Oct 3, 2017
…omez

 rustdoc: Render [src] links for trait implementors

Should close #43893.

<s>No tests [yet].</s>

r? @QuietMisdreavus
@bors
Copy link
Contributor

bors commented Oct 3, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: GuillaumeGomez
Pushing 61bad30 to master...

@bors bors merged commit acef039 into rust-lang:master Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rustdoc should emit [src] link for "Implementors" section also for traits.
6 participants